<link href="/css/express.css" media="screen" rel="stylesheet" type="text/css" >
<style>
    td{padding:5px;border:1px solid #000}
    table th{text-align:right}
    table li{float:left;margin-right:30px;}
    input{width:50px;}
</style>
<div class="center">
	<div class="home">
    	<div class="home_left">
        	<?php echo $this->partial('tuan/menu.phtml',array('uCount' => $this->uCount,'menuId'=>$this->menuId,'user'=>$this->user)); ?>
        </div>
        <div class="home_right">
            <h1>设置运费</h1>
        </div>
        <div class="jisuantop">
            <div class="country" style="width:700px">
                <div class="jisz"></div>
                <div class="guojialeft">
                	<!--a标签悬停class="gjon"-->
                    <a href="#" class="gj">美国<i></i></a>
                    <div class="guojiaceng" style="display:none">
                        <div class="remen">
                        	<h3>热门国家和地区</h3>
                            <ul class="countrylist">
                            	<li><a href="#" id="c_us" cid="1">美国</a></li>
                            	<li><a href="#" cid="2">加拿大</a></li>
                            	<li><a href="#" cid="3">澳大利亚</a></li>
                            	<li><a href="#" cid="47">日本</a></li>
                            	<li><a href="#" cid="39">台湾</a></li>
                            	<li><a href="#" cid="4">新西兰</a></li>
                            	<li><a href="#" cid="5">英国</a></li>
                            	<li><a href="#" cid="42">马来西亚</a></li>
                            </ul>
                        </div>
                        <div class="allcountry">
                        	<h3>全部国家和地区</h3>
                        	<ul class="countryzm">
                                <?
                                foreach ($this->words as $char){
                                ?>
                                <li <?= $char=='A'?'class="zmon"':'' ?>><a href="#"><?= $char ?></a></li>
                                <? }
                                ?>
                            </ul>
                            <div id="countryTab">
                            <?
                            foreach ($this->words as $char){
                            ?>
                           <ul class="countrylist"  <?= $char=='A'?'':'style="display:none"' ?>>
                               <?
                               $citys= Application_Model_city::GetBySortCode($char);
                               foreach ($citys as $city){
                               ?>
                            	<li><a href="#" cid="<?= $city->Id ?>"><?= $city->Name ?></a></li>
                                <? } ?>
                            </ul>
                            <?
                                }
                            ?>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="guojiaright">
                    <div class="count" style="width:300px;">
                    	<label>运费估算：</label>
                        <div class="js">
                        	
                        	<input type="text" id="weight" name="weight" />KG
                        </div>
                        <a class="toolbutton" id="cultbutton" href="#"><span>计算</span></a>
                    </div>
                    
                </div>
                <div>快递：<?= $this->formSelect('express',2,NULL,array('fedex'=>'Fedex','dhl'=>'DHL','ems'=>'EMS','air'=>'AIR','ups'=>'UPS')) ?></div>
                <div>利润率：<?= $this->formText('li',1.4) ?></div>
            </div>
            
        </div>
        <div class="ipcountry" style="width:700px;float:right">
            <div id="uuchPrice">
                正在获取悠奇价
            </div>
            <div id="shipTable">
                正在获取成本价...
            </div>
            <div id="px4">
                正在调用递四方API...
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
$(function(){
    $('.guojialeft').hover(function(){
        $('.guojiaceng').show();
        $('.gj').addClass('gjon');
    },function(){
        $('.guojiaceng').hide();
        $('.gj').removeClass('gjon');
    });
    $('.countrylist a').bind('click',function(){
        var city =$(this).text();
        $('.gj').html(city +'<i></i>');
        $('.gj').attr('cid', $(this).attr('cid'));
        $('.guojiaceng').hide();
        $('.ipcountry h2').html('正在获取'+ city + '运费,请稍候...' );
        $('#shipTable').html('正在获取成本价...')
        $('#px4').html('正在调用递四方API...');
        $.post('/tuan/uuchprice', {'cityId':$('.gj').attr('cid'),'express':$('#express').val()}, function(html){
            $('#uuchPrice').html(html);
        }, 'html');
        $.post('/tuan/shipfeedetail', {'cityId':$(this).attr('cid'),'express':$('#express').val()}, function(html){
            $('.ipcountry h2').html('寄送至“'+city+ '”的运费报价:' );
            $('#shipTable').html(html)
        }, 'html');
        $.post('/tuan/shipfeepx', {'cityId':$('.gj').attr('cid'),'express':$('#express').text()}, function(html){
            $('#px4').html(html);
        }, 'html');
        
        return false;
    });
    $('.countryzm a').each(function(index,item){
        $(item).click(function(){
            $('.countryzm li.zmon').removeClass('zmon');
            $(this).parent().addClass('zmon');
            $('#countryTab ul').hide();
            $('#countryTab ul').eq(index).show();
            return false;
        });
    });
    $('#cultbutton').click(function(){
        $('#cultbutton span').text('计算');
        var city = $('.gj').text();
        $('#shipTable').html('正在获取成本价...')
        $('#px4').html('正在调用递四方API...');
        $.post('/tuan/shipfeedetail', {'cityId':$('.gj').attr('cid'),'weight':parseFloat($('#weight').val())*1000}, function(html){
            $('.ipcountry h2').html('寄送至“'+city+ '”的运费报价:' );
            $('#shipTable').html(html)
        }, 'html');
        $.post('/tuan/shipfeepx', {'cityId':$('.gj').attr('cid'),'weight':parseFloat($('#weight').val())}, function(html){
            $('#px4').html(html);
        }, 'html');
        
        return false;
        
    });
    $('.jieguoclose').click(function(){
        $('.jieguo').slideUp('fast');
        return false;
    })
    $("#c_us").click();
    
    $("#weight").bind('keyup',function(){
                
		if($(this).val()=='')
			$(this).prev().show();
		else
			$(this).prev().hide();
	});
    $('.js p').click(function(){
        $("#weight").focus();
    });
    $('.global_kd a').click(function(){
        $('.yftable table').before('正在获取的' + $(this).text() + '报价,请稍候...');
        
        $.post('/tool/getfeetype', {'tid':$(this).attr('tid')}, function(html){
            $('.yftable').html(html);
        }, 'html');
        $('.global_kd li.kdon').removeClass('kdon');
        $(this).parent().addClass('kdon');
        return false;
    });
    $('.whylist li').each(function(index,item){
        $('a',item).click(function(){
            $(this).parent().next().slideToggle('fast');
            $(this).parent().toggleClass('kaion');
            _gaq.push(['_trackEvent', '快递介绍', '展开', $(item).text()]);
            return false;
        });
        
    });
    
    
    $('.kuaidi').hover(function(){
        //$('.kdtc').show();
    }, function(){
        $('.kdtc').hide();
    });
    
    $('.kuaidi .input').click(function(){
        $('.kdtc').show();
    });
    
    $('.kdzm a').each(function(index,item){
        $(item).click(function(){
            $('.kdzm .kon').removeClass('kon');
            $(this).parent().addClass('kon');
            $('#kdTab ul').hide();
            $('#kdTab ul').eq(index).show();
            return false;
        });
    });
    $('.kdlist a').click(function(){
        $('#expressname').val($(this).text());
        $('#expressid').val($(this).attr('cid'));
        $('.kdtc').hide();
        return false;
    });
    $('#express_submit').click(function(){
        $(this).attr('href','/member/instore?expressid='+ $('#expressid').val()+'&expressno='+$('#expressno').val());
    });
    $('.read').live('click',function(){
        $('.erow').hide();
        $('.'+$(this).attr('data')).show();
    });
});    
</script>

